package org.zlb.manager.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.zlb.manager.dao.FunParamDao;
import org.zlb.manager.entity.FunParam;
import org.zlb.manager.entity.FunParamPK;

import java.util.List;

/**
 * TODO
 *
 * @author zhoulingbo
 * @date 2021/8/10 14:02
 */
@Component
public class FunParamService {

    @Autowired
    private FunParamDao funParamDao;

    public List<FunParam> list() {
        return funParamDao.findAll();
    }

    public FunParam item(String paramGroup, String paramKey) {
        FunParamPK id = new FunParamPK();
        id.setParamGroup(paramGroup);
        id.setParamKey(paramKey);
        return funParamDao.getById(id);
    }

    public FunParam save(FunParam funParam) {
        return funParamDao.save(funParam);
    }

    public void delete(String paramGroup, String paramKey) {
        FunParamPK id = new FunParamPK();
        id.setParamGroup(paramGroup);
        id.setParamKey(paramKey);
        funParamDao.deleteById(id);
    }

    public long count() {
        return funParamDao.count();
    }
}
